package com.baidu.push.example;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

import com.baidu.android.pushservice.PushManager;
import com.chinatelecom.epush.R;

public class SettingFragment extends Fragment {
	private Button setTagButton, delTagButton, listTagButton;
	private Intent intent;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View settingLayout = inflater.inflate(R.layout.setting_layout,
				container, false);
		
		setTagButton = (Button)settingLayout.findViewById(R.id.setTagButton);
		delTagButton = (Button)settingLayout.findViewById(R.id.delTagButton);
		listTagButton = (Button)settingLayout.findViewById(R.id.listTagButton);
		
		setTagButton.setOnClickListener(new ButtonClick());
		delTagButton.setOnClickListener(new ButtonClick());
		listTagButton.setOnClickListener(new ButtonClick());
		return settingLayout;
	}
	
	class ButtonClick implements OnClickListener{

		@Override
		public void onClick(View v) {
			if(v.getId() == R.id.setTagButton){
				intent = new Intent();
				intent.setClass(getActivity(), SetTagActivity.class);
				startActivity(intent);
			}else if(v.getId() == R.id.delTagButton){
				intent = new Intent();
				intent.setClass(getActivity(), DelTagActivity.class);
				startActivity(intent);
			}else if(v.getId() == R.id.listTagButton){
				PushManager.listTags(getActivity());
			}
		}
	}
}
